using System;

namespace FreshMeat.ErrorHandlingBlock.Wcf
{
   /// <summary>
   /// Policy for common transient errors encountered by clients using WCF (Windows Communication Foundation).
   /// </summary>
   public class WcfTransientErrorPolicy : ErrorPolicy
   {
      static readonly TimeSpan initialWait = TimeSpan.FromSeconds(0.1); // Retry almost immediately after first failure
      static readonly TimeSpan increase = TimeSpan.FromSeconds(1); // increase this amount after subsequent failures
      static readonly TimeSpan maxWait = TimeSpan.FromSeconds(10); // remember that total cummulative wait is longer than this

      /// <summary>
      /// Creates default instance.
      /// </summary>
      public WcfTransientErrorPolicy()
         : base(new WcfTransientErrorDetector(), new LinearRetryPlan(5, initialWait, increase, maxWait))
      {
      }
   }
}